<script setup>
import { getClssListAPI, getArticleListAPI } from '../../api/index'

const classList = ref()
const choose = ref([]) // 选择的标签
const search = ref("")
const articleList = ref([])

// 获取文章列表
async function getClassList() {
    const res = await getClssListAPI()
    classList.value = res.data.value.rows
}
// 获取提示词列表
async function getArticleList() {
    const res = await getArticleListAPI({
        classIds: choose.value,
        title: search.value
    })
    articleList.value = res.data.value.data
}

// 选择class标签
function onClick(item) {
    const index = choose.value.indexOf(item); // 检查元素是否已经存在于数组中
    if (index !== -1) {
        // 如果元素已经存在，则移除
        choose.value.splice(index, 1);
    } else {
        // 否则，添加元素
        choose.value.push(item);
    }
    getArticleList()
}

getClassList()
getArticleList()
</script>

<template>
    <div class="container">
        <div class="nav-pic">
            <!-- <div class="index-img-mask"></div> -->
            <div class="nav-top">
                AI提示词
            </div>
            <div class="nav-top-text">
                让生产力加倍的快捷指令
            </div>
            <div class="tools-search-box">
                <div class="tools-search-boxs">
                    <input type="search" class="tools-search" placeholder="请在这输入搜索的内容"v-model="search">
                    <div class="tools-search-btn" @click="getArticleList">
                        搜索一下
                    </div>
                </div>
            </div>
        </div>

        <div class="nav-tag clearfix">
            <div class="nav-tag-title">
                <div>
                    标签
                </div>
                <div style="margin-left: 10px;color: #8E8E8E;font-size: 16px;">
                    Tag
                </div>
            </div>
            <div class="nav-tag-text">
                <div v-for="(item, index) in classList" :key="index" class="nav-tag-text-box"
                    :class="{ active: choose.includes(item.classId) }" @click="onClick(item.classId)">
                    {{ item.className }}
                </div>
            </div>
        </div>
        <div class="nav-prompt clearfix">
            <div class="nav-prompt-title">
                <div>
                    提示词
                </div>
                <div style="margin-left: 10px;color: #8E8E8E;font-size: 16px;">
                    key words
                </div>
            </div>
            <div class="Rectangle 79">
                <ul class="nav-prompt-box-ul">
                    <li class="nav-prompt-title-box" v-for="(item, index) in articleList" :key="index">
                        <div class="nav-prompt-box-text" v-html="item.content">

                        </div>
                        <div class="nav-prompt-box-title">
                            <div class="nav-prompt-box-title-text">
                                <span>{{ item.title }}</span>
                                <div class="nav-prompt-box-title-intro">
                                    {{ item.introduction }}
                                </div>
                            </div>
                            <!-- <div class="nav-prompt-box-title-btn">复制</div> -->
                        </div>
                        <div class="nav-prompt-box-tag">
                            <ul>
                                <li class="nav-prompt-box-tag-text"
                                    v-for="(items, index) in item.forumAtricleClassVOList">{{ items.className }}</li>
                            </ul>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>

<style scoped>
.clearfix::after {
    content: '.';
    display: block;
    visibility: hidden;
    height: 0;
    line-height: 0;
    clear: both;
}

ul {
    list-style: none;
}

.container {
    width: 100%;
    /* max-width: 1170px; */
    margin: 0 auto;
    height: 100%;
    min-height: 100vh;
    /* padding: 20px; */
    display: flex;
    flex-direction: column;
    /* justify-content: center; */
    align-items: center;

}

.nav-pic {
    width: 100%;
    height: 400px;
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: url('../../static/indexbg.png') center/cover;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.index-img-mask {
    z-index: -999;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, .4);
}

.nav-top {
    /* width: 125px; */
    height: 42px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 600;
    font-size: 38px;
    color: #1F1F1F;
    line-height: 35px;
    letter-spacing: 1px;
    text-align: left;
    font-style: normal;
    text-transform: none;
    margin-bottom: 20px;
}

.nav-top-text {
    /* width: 200px; */
    height: 17px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 300;
    font-size: 16px;
    color: #8E8E8E;
    line-height: 14px;
    letter-spacing: 6px;
    text-align: left;
    font-style: normal;
    text-transform: none;
}

.nav-tag {
    width: 100%;
    max-width: 1170px;
    /* margin: 0 auto; */
    margin-top: 20px;
}

.nav-tag-title,
.nav-prompt-title {
    display: flex;
    flex-direction: row;
    align-items: center;
    font-weight: bold;
    font-size: 24px;
    color: #655aec;
}

.nav-tag-text-box {
    /* padding: 5px; */
    font-size: 14px;
    float: left;
    /* border: 1px solid #655aec; */
    margin-top: 10px;
    margin-left: 10px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.2);
    width: 72px;
    height: 28px;
    line-height: 28px;
    text-align: center
}

.nav-tag-text-box:hover {
    box-shadow: 0px 0px 2px 1px #655aec;
    cursor: pointer;
}

.nav-prompt {
    width: 100%;
    max-width: 1170px;
    padding-top: 50px;
}

.nav-prompt-box {
    width: 100%;
    max-width: 1170px;
}

.nav-prompt-box-ul {
    width: 100%;
    max-width: 1170px;
    display: flex;
    flex-wrap: wrap;
    /* 换行 */
}

.nav-prompt-title-box {
    display: flex;
    margin: 10px;
    /* float: left; */
    /* height: 100%; */
    /* width: 250px; */
    /* max-height: 350px; */
    /* padding: 15px; */
    box-shadow: 0 0 10px #0003;
    /* border: 1px solid #655aec; */
    border-radius: 10px;
    /* align-items: stretch; */
    flex-direction: column;
    /* flex-grow: 1; */
}

.nav-prompt-box-title {
    /* width: 240px; */
    /* height: auto; */
    /* max-height: 300px; */
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    border-top: 2px dashed #E1E1E1;
    padding-top: 15px;
    padding-left: 15px;
    /* flex-grow: 1; */
}

.nav-prompt-box-title-text {
    color: #655aec;
    font-weight: bold;
    cursor: default;
    width: 240px;
}

span {
    position: relative;
}

span::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: #655aec;
    transform-origin: center;
    transform: translate(-50%, 0) scaleX(0);
    transition: transform 0.3s ease-in-out;
}

span:hover::before {
    transform: translate(-50%, 0) scaleX(1);
}

.nav-prompt-box-title-btn {
    border-radius: 10px;
    border: 1px solid #ccc;
    height: 15px;
    padding: 5px;
    font-size: 14px;
    line-height: 15px;
    cursor: pointer;
}

.nav-prompt-box-title-btn:hover {
    background-color: #655aec;
    color: #fff;
}

.nav-prompt-box-text {
    padding: 15px;
    overflow: hidden;
    overflow-y: auto;
    width: 240px;
    height: 260px;
    font-size: 12px;
    scrollbar-width: thin;
}

.nav-prompt-box-title-intro {
    /* align-items: stretch; */
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    color: #333;
    font-size: 13px;
    font-weight: 100;
    display: flex;
    width: 240px;
}

.nav-prompt-box-tag ul {
    width: 100%;
    height: 30px;
    display: flex;
    flex-direction: row;
    float: left;
    /* flex-direction: row; */
    /* justify-content: left; */
    /* margin-bottom: 10px; */
    padding-left: 15px;
    box-sizing: border-box;
    /* flex-direction: row; */
    padding-bottom: 10px;
    /* align-items: stretch; */
}

.nav-prompt-box-tag-text {
    /* width: 50px; */
    /* width: auto; */
    display: flex;
    align-items: center;
    /* flex-direction: row; */
    font-size: 12px;
    padding: 5px;
    margin-right: 5px;
    border-radius: 10px;
    background-color: #E4E7FE;
    color: #1A25F3;
    cursor: default;

}

.active {
    background-color: #655aec;
    color: #fff;
    border: 1px solid #655aec;
}

.tools-search-box {
    margin-top: 20px;
    width: 100%;
    max-width: 1170px;
    /* padding: 30px; */
    display: flex;
    justify-content: center;
    align-items: center;
}

.tools-search {
    /* border: none; */
    border: 1px solid rgba(26, 37, 243, 0.5);
    /* border: 1px solid #655aec; */    
    width: 100%;
    max-width: 468px;
    height: 40px;
    /* margin: 2px 5px; */
    outline: 0 none;
    /* border-radius: 20px; */
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    font-size: 16px;
    padding: 10px;
}

.tools-search-boxs {
    width: 100%;
    max-width: 1170px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.tools-search-btn {
    width: 108px;
    height: 40px;
    border-bottom-right-radius: 10px;
    border-top-right-radius: 10px;
    text-align: center;
    line-height: 40px;
    color: #fff;
    /* font-size: 24px; */
    background-color: #1A25F3;
}

.nav-prompt-title-box:hover {
    box-shadow: 0 0 10px #655aec;
}

@media (max-width: 992px) {
    .nav-prompt-title-box {
        width: 330px;
    }

    .nav-prompt-box-text {
        width: 300px;
    }

    .nav-tag,
    .nav-prompt {
        /* padding: 20px; */
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
    }

    .nav-prompt-box-title {
        font-size: 22px;
    }

    .nav-prompt-box-text {
        font-size: 16px;
    }

    .nav-prompt-box-ul {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }
}
</style>